using System;
using System.Collections.Generic;
using System.Text;
using BaseTreeList = DevExpress.XtraTreeList;
using BaseTreeListNodes = DevExpress.XtraTreeList.Nodes;
namespace THSLib
{
    #region --TreeList--
    public class THSTreeListObject:BusinessObject
        {
            #region Variables
            protected THSTreeListObject _parent;
            protected BaseTreeList.TreeList _subList = new BaseTreeList.TreeList();
            protected bool _selected = false;
        protected BaseTreeListNodes.TreeListNodes _nodes;
            #endregion

            #region Public properties
            public THSTreeListObject Parent
            {
                get
                {
                    return _parent;
                }
                set
                {
                    _parent = value;
                }
            }

            public BaseTreeList.TreeList SubList
            {
                get
                {
                    return _subList;
                }
                set
                {
                    _subList = value;
                }
            }

            public bool Selected
            {
                get
                {
                    return _selected;
                }
                set
                {
                    _selected = value;
                }
            }
        public BaseTreeListNodes.TreeListNodes Nodes
            {
                get
                { 
                    return SubList.Nodes;
                }
                
            }
        public int Count
        {
            get { return Nodes.Count; }
        }
            #endregion

            public bool HasChildren()
            {
                if (this.SubList.HasChildren)
                    return true;
                return false;
            }

            public bool HasSelectedChildren()
            {
                foreach (THSTreeListObject obj in this.SubList.Nodes)
                {
                    if (obj.HasChildren() == false && obj.Selected)
                        return true;
                    else
                    {
                        bool result = obj.HasSelectedChildren();
                        if (result)
                            return true;
                    }
                }
                return false;
            }
        }
#endregion
}
